function _createStyle(color, deg = '0deg', linear1, linear2) {
  return `color: ${color};background: linear-gradient(${deg}, ${linear1} 0%, ${linear2} 100%);`
}

const STYLE = {
  BASE: 'font-size: 12px;padding:2px 4px;border-radius: 4px;',
  INFO: _createStyle('#00244d', '-60deg', '#16a085', '#f4d03f'),
  WARN: _createStyle('#fff7d3', '-60deg', '#ff5858', '#f09819'),
  ERROR: _createStyle('#e74c3c', '-225deg', '#D7FFFE', '#FFFEFF'),
}

function log(type, title, ...args) {
  const console = window.console
  const hasVconsole = !!window.__VCONSOLE_INSTANCE || !!window._vcOrigConsole
  const style = STYLE.BASE + STYLE[type]
  const content = hasVconsole ? [`${title} --> `, ...args] : ['%c%s', style, title, ...args]
  console.log(...content)
}

export const info = log.bind(null, 'INFO')
export const warn = log.bind(null, 'WARN')
export const error = log.bind(null, 'ERROR')
